<%@ include file="/html/common/init.jsp"%>

<style type"text/css">
.ie7 #tspc{
Position:relative;
left: 16px;
}

.ie8 #tspc{
Position:relative;
left: 16px;
}
</style>

<portlet:actionURL name="addProcess" var="searchURL">
			<portlet:param name="<%= Constants.CMD %>" value="<%= Constants.SEARCH %>" />
			<portlet:param name="redirect" value="<%= currentURL %>" />
</portlet:actionURL>

<%
List<ShoppingItem> list=null;

PortletSession psession=renderRequest.getPortletSession();
List<ShoppingItem> searchItemList=(List<ShoppingItem>)psession.getAttribute("SEARCH_ITEMLIST");

int count = ShoppingItemLocalServiceUtil.getShoppingItemsCount();
List<ShoppingItem> itemlist = ShoppingItemLocalServiceUtil.getShoppingItems(0, count);
if(Validator.isNotNull(searchItemList)){
	list=searchItemList;
}
else{
	list=itemlist;
}
%>
<aui:form name="fm" action="<%=searchURL%>" method="post">
<table><tr><td width="12%" style="font-weight:bold;">Item Name</td><td width="10%"><aui:input name="searchData" label="" type="text" /></td>
<td id="tspc" width="25%"><input type="submit" value="Search" /></td>
</tr>
<tr><td><br/></td></tr>
</table>



</aui:form>
<liferay-ui:search-container emptyResultsMessage="there-are-no-products"
	delta="5">
	<liferay-ui:search-container-results>
		<%
					results = ListUtil.subList(list,searchContainer.getStart(),searchContainer.getEnd());
					total = list.size();
					pageContext.setAttribute("results", results);
					pageContext.setAttribute("total", total);
		%>
	</liferay-ui:search-container-results>


	<portlet:renderURL var="addURL">
		<portlet:param name="jspPage"
			value="/html/item/edit_item.jsp" />
	</portlet:renderURL>
	   <% 
			PortletURL rowURL = renderResponse.createRenderURL();
			rowURL.setParameter("jspPage", "/html/item/view_item.jsp");
			rowURL.setParameter("redirect", currentURL);
	 %>
	<a href="<%=addURL.toString()%>"><input type="button"
		value="Add Item" /></a>

	<br />
	<br />

	<liferay-ui:search-container-row
		className="com.liferay.portlet.shopping.model.ShoppingItem"
		keyProperty="itemId" modelVar="shoppingItem">
		<%
rowURL.setParameter("itemId", String.valueOf(shoppingItem.getItemId()));
		 %>
		<liferay-ui:search-container-column-text name="SKU" property="sku" 
		    href="<%=rowURL.toString() %>"/>
		<liferay-ui:search-container-column-text name="Item Name"
			property="name" href="<%=rowURL.toString() %>" />
		<liferay-ui:search-container-column-text name="Min Qty"
			property="minQuantity" href="<%=rowURL.toString() %>"/>
		<liferay-ui:search-container-column-text name="Price" 
		    property="price" href="<%=rowURL.toString() %>"/>
		<liferay-ui:search-container-column-text name="max Qty"
			property="maxQuantity" href="<%=rowURL.toString() %>" />

		<liferay-ui:search-container-column-jsp
			path="/html/item/item_action.jsp" align="right" />
	</liferay-ui:search-container-row>
	<liferay-ui:search-iterator></liferay-ui:search-iterator>
</liferay-ui:search-container>
<%
psession.removeAttribute("SEARCH_ITEMLIST");
%>